package com.dz.scrm.mvp.model.repository

import com.dz.scrm.mvp.model.entity.*
import com.dz.scrm.mvp.model.service.UserService
import io.reactivex.Observable
import me.jessyan.art.mvp.IModel
import me.jessyan.art.mvp.IRepositoryManager
import retrofit2.http.Body
import retrofit2.http.GET

/**
 * 作者：fanda
 * 日期：2021/4/21 19:07
 * 描述：必须实现 IModel
 * 可以根据不同的业务逻辑划分多个 Repository 类,多个业务逻辑相近的页面可以使用同一个 Repository 类
 * 无需每个页面都创建一个独立的 Repository
 * 通过 [IRepositoryManager#createRepository(Class)] 获得的 Repository 实例,为单例对象
 *
 *  真正的数据请求类，比如这里只放 User 相关的接口请求
 */

// 必须含有一个接收 IRepositoryManager 接口的构造函数,否则会报错
class UserRepository(private val manager: IRepositoryManager) : IModel {

    fun getCode(phoneNum: String): Observable<BaseResponse<MsgCodeBean?>> {
        return manager.createRetrofitService(UserService::class.java).getCode(phoneNum)
    }

    fun Login(lastIdQueried: String, code: String): Observable<BaseResponse<LoginBean?>> {
        return manager.createRetrofitService(UserService::class.java).Login(lastIdQueried, code)
    }

    fun CheckCompany(phoneNum: String, tenantId: String, verify: String,registrationId: String): Observable<BaseResponse<CompanyInfoBean?>> {
        return manager.createRetrofitService(UserService::class.java).checkCompany(phoneNum, tenantId, verify,registrationId)
    }

    /*检测更新*/
    fun checkVersion():Observable<BaseResponse<CheckVersionBean?>> {
        return manager.createRetrofitService(UserService::class.java).checkVersion()
    }

    // 通话记录上传
    fun postPhoneRecord(params: PhoneRecordParams): Observable<BaseResponse<DZResponse?>>{
        return manager.createRetrofitService(UserService::class.java).postPhoneRecord(params)
    }

    //获取拨打电话名字
    fun GetUerPhoneName(customerPhone: String): Observable<BaseResponse<LoginCompanyBean?>> {
        return manager.createRetrofitService(UserService::class.java).GetUerPhoneName(customerPhone)
    }
    override fun onDestroy() {

    }
}